﻿// Fill out your copyright notice in the Description page of Project Settings.


#include "Actor/CreateEnemyPoint.h"

#include "AIController.h"
#include "GameMode/CombatGameMode.h"
#include "Helper/DebugHelper.h"
#include "Kismet/GameplayStatics.h"


// Sets default values
ACreateEnemyPoint::ACreateEnemyPoint()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void ACreateEnemyPoint::BeginPlay()
{
	Super::BeginPlay();

	//put to gamemode point list
	ACombatGameMode* GameMode = Cast<ACombatGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
	GameMode->AddCreatePoint(this);
}

// Called every frame
void ACreateEnemyPoint::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ACreateEnemyPoint::CreateEnemy()
{
	// Debug::printLog("created one enemy!");
	if (EnemyClasses.Num() > 0)
	{
		int32 RandRangeClass = FMath::RandRange(0, EnemyClasses.Num() - 1);
		GetWorld()->SpawnActor<AEnemyCharacter>(EnemyClasses[RandRangeClass], this->GetTransform());
	}
}
